package cn.com.cabinet.manager.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.com.easy.utils.CookieUtils;

@Controller
@RequestMapping("/manager")
public class IndexController {

	@RequestMapping("/index")
	public String redirectIndex(HttpServletRequest request,ModelMap modelMap) throws Exception{
		String adminCount = CookieUtils.getCookieValue(request, "adminCount");
		System.out.println("loginCheck:"+adminCount);
		if(adminCount == "null" || adminCount == null){
			return "/login/admin_login";
		}else{
			System.out.println("----start index----");
			modelMap.addAttribute("adminCount", adminCount);
			return "/index/index";
		}
				
	}
	
	@RequestMapping()
	public String Index(HttpServletRequest request,ModelMap modelMap) throws Exception{
		String adminCount = CookieUtils.getCookieValue(request, "adminCount");
		System.out.println("loginCheck:"+adminCount);
		if(adminCount == "null" || adminCount == null){
			return "/login/admin_login";
		}else{
			System.out.println("----start index----");
			modelMap.addAttribute("adminCount", adminCount);
			return "/index/index";
		}
		
	}

}
